home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
APP
/
A-D
/
Alpha.4.01.cpt
/
Alpha.4.01.rsrc
/
STR#_132.txt
< prev
next >
Wrap
Text File
|
1991-10-22
|
7KB
|
337 lines
ANSI-A4 should take care of most of your library needs.
instead of A5. Linking your code with MacTraps and
but there is a version of the ANSI library that uses A4
ThinkC is fine. The ANSI library does declare globals,
global data references off of register A5. MacTraps of
be taken to ensure that the libraries don't have any
If the ACMD needs to link in library routines, care must
interested.
decade that comes out. IM 6 has a workaround, for those
under A/UX, and probably not under system 8.0, whatever
value of A4 on entry. Self-modifying code will not work
that these routines use self-modifying code to store the
with "RestoreA4()". MPW has similar setup routines. Note
to "RememberA0()" and "SetUpA4()", and it should end
header "SetUpA4.h", your program should begin with calls
this means is that your main file must include the
From the standpoint of a C compiler like Think C, all
their data off of register A4 instead of the usual A5.
Since ACMDs are code resources, they must reference
resource fork by using ResEdit.
bound to keystrokes). ACMDs can be added to Alpha's
callable from macros (macros allow ACMD functions to be
are added to the ACMD menu under 'Utilities' and are
Code resources of type 'ACMD' in Alpha's resource fork
• The ACMD resource is released.
transformed text.
• The original selection is replaced with the
NULL as it's result.
• The ACMD transforms the string, and returns it or
parameters.
the text pointer and the function pointers as it's
• The 'ACMD' resource is called as a 'C' function w/
carriage returns to delimit lines.
pointer. The string will be null-terminated w/
• The selection (if any) is copied into the new
size of the current selection + 1.
• A new pointer is allocated with size equal to the
and locked.
• The selected code resource is loaded into memory
In summary, when an ACMD is called:
used internally.
an Alpha internal variable, only 16 bits are actually
So even while you MUST pass in a longword value to set
variables such as 'indentOnCR' and 'regExpr' are shorts.
Alpha string variables are long words, ordinary Alpha
persistent storage. Note that while user variables and
also hold pointer values, allowing ACMDs to have
defining their own variables. ACMD-defined variables can
are viewing. ACMDs can pass data among themselves by
according to the current state of Alpha and the text you
These functions allow your ACMDs to behave differently
int deleteVar(char *name);
*******************************************/
* *
* Return 0 if the variable doesn't exist. *
* Define a longword variable named 'name'. *
* *
/*******************************************
int defineVar(char *name, long val)
************************************************/
* *
* Return 0 if the var already exists. *
* Initial value 'val'. *
* Define a longword variable named 'name' with *
* *
/************************************************
int setVar(char *name, long val);
***********************************************/
* *
* 'val' to a long when you call this routine. *
* a longword value for 'val', always typecast *
* doesn't exist. To be sure that Think passes *
* 'defineVar' below. Returns 0 if the var *
* predefined vars or those defined with *
* named by 'name'. Works for either Alpha *
* Return the longword value of the variable *
* *
/***********************************************
int getVar(char *name, long *val);
***********************************************/
* *
* doesn't exist. *
* 'defineVar' below. Returns zero if the var *
* Alpha predefined vars or those defined with *
* named by 'name' in 'val'. Works for either *
* Return the longword value of the variable *
* *
/***********************************************
functions as:
Alpha variables. Internally, Alpha prototypes these
Alpha function that your ACMD can call to read or modify
Each of the last four parameters is a pointer to an
'%ld' instead of '%d'.
with 32-bit ints, you must print your integers with
are calling Alert from a code resource that was compiled
that Alpha is compiled with 16-bit integers, so if you
displaying the result in an alert box. Bear in mind
accepts the same arguments as the C 'printf' command,
The 'alert' parameter is a pointer to a function that
display information.
ACMD to interact with Alpha's internal variables or
callback function, an Alpha function that allows your
Each of the last five arguments is a pointer to a
Callback Functions
selections.
selected text. However, macros can call ACMDs with other
is performed. 'text' is usually a copy of the currently
when the ACMD returns NULL. In this case no deallocation
block of text returned by the ACMD. The exception is
deallocating the input block. Alpha will deallocate the
two are not the same block, you are responsible for
similarly allocated block of text as its result. If the
allocated with 'NewPtr'. Your routine must return a
'text' points to a null-terminated block of text
}
return (text);
: : :
{
FPtr alert, getVar, setVar, defVar, delVar;
char *text;
delVar)
char *main(text, alert, getVar, setVar, defVar,
typedef int (*FPtr)();
/* pointer to a function that returns an 'int' */
should be declared:
The following is the way the 'main' routine of your ACMD
play sounds.
distribution wrap text, insert the current data, and
ACMD invocations. Example ACMDs included in this
as well as define variables that Alpha maintains between
as a result. ACMDs can access Alpha flags and variables,
the text and returns a pointer to the transformed text
text (usually the selected text). The ACMD transforms
is loaded, it is passed a pointer to a chunk of file
for Alisp functions, or would be too slow. When an ACMD
typically implement functionality that is too complex
modules of user-written code to Alpha. These modules
Code resources of type 'ACMD' allow the user to add
ACMDs